package Spring;

import org.example.Spring.Service.UserService;
import org.example.Spring.User1;
import org.example.Spring.User2;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class testUser {
    @Test
    public void testUser1(){
        ApplicationContext applicationContext = new
                ClassPathXmlApplicationContext("Spring-context.xml");
        User1 user1 = (User1) applicationContext.getBean("User1");
        System.out.println(user1);     //默认调用该对象的toString方法
    }
    @Test
    public void testUser2(){
        ApplicationContext applicationContext = new
                ClassPathXmlApplicationContext("Spring-context.xml");
        User2 user2 = (User2) applicationContext.getBean("User2");
        System.out.println(user2);
    }

    @Test
    public void testUser(){
        ApplicationContext applicationContext = new
                ClassPathXmlApplicationContext("Spring-context.xml");
        UserService userService = (UserService) applicationContext.getBean("UserService");
        boolean flag = userService.login("yy","123456");
        if(flag){
            System.out.println("登录成功");
        }else{
            System.out.println("登录失败");
        }
    }
}
